package com.example.hello.client.Heading;

import com.example.hello.BootstrapHeading;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.shared.ui.Connect;

@Connect(BootstrapHeading.class)
public class BootstrapHeadingConnector extends AbstractComponentConnector {

    @Override
    protected Widget createWidget() {
        return GWT.create(VBootstrapHeading.class);
    }

    @Override
    public BootstrapHeadingState getState() {
        return (BootstrapHeadingState) super.getState();
    }

    @Override
    public VBootstrapHeading getWidget() {
        return (VBootstrapHeading) super.getWidget();
    }

    @Override
    public void onStateChanged(StateChangeEvent stateChangeEvent) {
        super.onStateChanged(stateChangeEvent);

        BootstrapHeadingState state = getState();

        VBootstrapHeading heading = getWidget();

//        VBootstrapHeading heading = new VBootstrapHeading(state.getSize());
        heading.setText(state.getText());
        heading.setSubtext(state.getSubtext());
    }

}